package com.atguigu.gmall.cart.client;

import com.atguigu.gmall.cart.client.impl.CartDegradeFeignClient;
import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.cart.CartInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

/**
 * @author Fxz
 * @version 1.0
 * @date 2022-02-19 13:47
 */
@SuppressWarnings("all")
@FeignClient(value = "service-cart", fallback = CartDegradeFeignClient.class)
public interface CartFeignClient {

	/**
	 * 添加购物车 不需要加HttpServletRequest,因为feign拦截器处理了
	 */
	@PostMapping("/api/cart/addToCart/{skuId}/{skuNum}")
	public Result addToCart(@PathVariable("skuId") Long skuId, @PathVariable("skuNum") Integer skuNum);

	@GetMapping("/api/cart/getCartCheckedList/{userId}")
	public List<CartInfo> getCartCheckedList(@PathVariable("userId") Long userId);

	/**
	 * 跟据userId 加载购物车实时价格
	 */
	@GetMapping("/api/cart/loadCartCache/{userId}")
	Result loadCartCache(String userId);

}
